package com.ld.security.server.admin.modules.ge.api;

import com.ld.security.common.mybatis.base.po.IdPo;
import com.ld.security.common.mybatis.base.vo.DataVo;
import com.ld.security.common.tomcat.base.api.SuperApi;
import com.ld.security.server.admin.modules.ge.entity.GeProjectEntity;
import com.ld.security.server.admin.modules.ge.mapping.ProxyMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags="工程Api管理")
@RequestMapping("/api/geProject")
public class GeProjectApi extends  SuperApi<GeProjectEntity> {


    @Autowired
    ProxyMapping proxyMapping;

    String[] tables={
            "ge_table",
            "ge_column",
            "ge_model",
            "ge_view",
            "ge_field"
    };

    @ApiOperation("清空工程数据")
    @RequestMapping(value = "/flushDb",method = RequestMethod.POST)
    public DataVo flushDb(@RequestBody IdPo po) {
        int total = 0;
        for (String table : tables) {
            String sql="delete from "+table;
            total += proxyMapping.update("",sql,null);
        }
        return DataVo.ofMsg("清空工程成功,删除"+total+"条数据");
    }



}
